﻿using System;
using System.Collections;
using Manager;
using UnityEngine;

// Token: 0x0200033D RID: 829
public class LoadSound : LoadAudioBase
{
	// Token: 0x06001500 RID: 5376 RVA: 0x00090618 File Offset: 0x0008E818
	public override IEnumerator _Init()
	{
		if (base.initialized)
		{
			yield break;
		}
		//if (!this.isAssetEqualPlay && Singleton<Sound>.Instance.FindAsset(this.type, this.assetName, this.assetBundleName) != null)
		//{
		//	Transform parent = base.transform.parent;
		//	if (parent != null)
		//	{
		//		if (parent.GetComponent<AudioSource>() != null)
		//		{
		//			this.isReleaseClip = false;
		//			UnityEngine.Object.Destroy(parent.gameObject);
		//			base.initialized = true;
		//			yield break;
		//		}
		//	}
		//	else if (base.transform.GetComponent<LoadAudioBase>() != null)
		//	{
		//		this.isReleaseClip = false;
		//		UnityEngine.Object.Destroy(base.gameObject);
		//		base.initialized = true;
		//		yield break;
		//	}
		//}
		if (this.isAsync)
		{
			yield return base.StartCoroutine(base._Init());
		}
		else
		{
			base.StartCoroutine(base._Init());
		}
		if (base.clip == null)
		{
			yield break;
		}
		//Singleton<Sound>.Instance.Bind(this);
		base.name = "Sound LoadEnd";
		yield break;
	}

	// Token: 0x06001501 RID: 5377 RVA: 0x00090634 File Offset: 0x0008E834
	protected override IEnumerator Start()
	{
		base.enabled = false;
		if (base.audioSource == null)
		{
			yield return base.StartCoroutine(this._Init());
		}
		while (!base.isLoadEnd)
		{
			yield return null;
		}
		if (base.clip == null)
		{
			yield break;
		}
		//if (this.type == Sound.Type.BGM)
		//{
		//	this.fadeTime = Mathf.Max(this.fadeTime, 0.01f);
		//	base.StartCoroutine(base.Play(Singleton<Sound>.Instance.currentBGM, delegate(GameObject go)
		//	{
		//		Singleton<Sound>.Instance.currentBGM = go;
		//	}));
		//}
		//else
		//{
		//	base.StartCoroutine(base.Play(null, null));
		//}
		base.enabled = true;
		yield break;
	}

	// Token: 0x0400194C RID: 6476
	//public Sound.Type type = Sound.Type.GameSE2D;

	// Token: 0x0400194D RID: 6477
	public bool isAssetEqualPlay = true;
}
